//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================

#include <string.h>

void AnsiToUnic(wchar_t *pwszName, const char *pszName)
{
    while (*pszName) {
        *pwszName++ = (wchar_t)*pszName++;
    }
    *pwszName = 0;
}

void UnicToAnsi(char *pszName, const wchar_t *pwszName)
{
    while (*pwszName) {
        *pszName++ = (char)*pwszName++;
    }
    *pszName = 0;
}

int MiscCmp(const char *pszName, const wchar_t *pwszName)
{
    while (*pszName && *pszName == *(char *)pwszName) {
        pszName++;
        pwszName++;
    }

    return (*pszName || *(char *)pwszName);
}

int MiscICmp(const char *pszName, const wchar_t *pwszName, size_t count)
{
	int c1, c2;
	if (count) {
		do {
        	c1 = *pszName++;
            if (c1 >= 'A' && c1 <= 'Z') // convert to lower case.
                c1 -= 'A' - 'a';

            c2 = *pwszName++;
            if (c2 >= 'A' && c2 <= 'Z') // convert to lower case.
                c2 -= 'A' - 'a';
		} while (--count && c1 && (c1 == c2));
    	return(c1 - c2);
	}
	return 0;
}
